﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class weixin_user : System.Web.UI.Page
{
    static DateTime date = DateTime.Now;
    //System.Data.DataSet ds = new System.Data.DataSet();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            date = DateTime.Now;
            string dateStr = date.ToShortDateString();
            Label1.Text = date.ToShortDateString();
            string strSql = "SELECT realToUserName,subscribe,createTime,fromUserName FROM MpUserInfo where createTime>'"+date.ToShortDateString()+"' and createTime<'"+date.AddDays(1).ToShortDateString()+"' order by createTime";
            TB.BLL.MpUserInfo user = new TB.BLL.MpUserInfo();
            System.Data.DataSet ds = user.GetDataSet(strSql);
            GridView1.DataSource = ds.Tables[0];
            GridView1.DataBind();
        }
    }
    protected void btnPre_Click(object sender, EventArgs e)
    {
        date = date.AddDays(-1);
        Label1.Text = date.ToShortDateString();
        string strSql = "SELECT realToUserName,subscribe,createTime,fromUserName FROM MpUserInfo where createTime>'" + date.ToShortDateString() + "' and createTime<'" + date.AddDays(1).ToShortDateString() + "' order by createTime";
        TB.BLL.MpUserInfo user = new TB.BLL.MpUserInfo();
        System.Data.DataSet ds = user.GetDataSet(strSql);
        GridView1.DataSource = ds.Tables[0];
        GridView1.DataBind();
    }

    private string WriteTable(System.Data.DataSet ds)
    {
        string table="<table cellspacing='0'>";
        string str="";
        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            str+= "<tr><td>" + dr[0].ToString() + "</td><td>" + dr[1].ToString() + "</td><td>" + dr[2].ToString() + "</td><td>" + dr[3].ToString() + "</td></tr>";
        }
        string tableEnd = "</table>";
        return table + str + tableEnd;

    }

    protected void btnNext_Click(object sender, EventArgs e)
    {
        date = date.AddDays(1);
        Label1.Text = date.ToShortDateString();
        string strSql = "SELECT realToUserName,subscribe,createTime,fromUserName FROM MpUserInfo where createTime>'" + date.ToShortDateString() + "' and createTime<'" + date.AddDays(1).ToShortDateString() + "' order by createTime";
        TB.BLL.MpUserInfo user = new TB.BLL.MpUserInfo();
        System.Data.DataSet ds = user.GetDataSet(strSql);
        GridView1.DataSource = ds.Tables[0];
        GridView1.DataBind();
    }
}